package com.qfoud.edu.aunt.commons.dao.impl;

import com.qfoud.edu.aunt.commons.dao.IRoleDAO;
import com.qfoud.edu.aunt.commons.pojo.Role;
import com.qfoud.edu.aunt.commons.utils.JdbcUtils;
import com.qfoud.edu.dbutils.framwork.result.impl.BeanListHandler;

import java.util.List;

/**
 * @author xiaobobo
 * @title: RoleDAO
 * @projectName cd-java-2303-project-parent
 * @description: TODO
 * @date 2023/5/16  10:24
 */
public class RoleDAO implements IRoleDAO {
    @Override
    public List<Role> findRolesByUserId(Integer userId) throws Exception {
        return JdbcUtils.queryRunner().query(
                "SELECT t2.* FROM t_user_role t1 JOIN t_role t2 ON t1.roleId=t2.roleId WHERE t1.userId=?",new BeanListHandler<Role>(Role.class),
                userId
        );
    }
}
